The use of computer software to automatically generate computer programs for performing a prescribed process is often called automatic code generation. Depending on the system, the prescribed process can be described by one of a number of "functional languages" rather than a conventional computer language. For instance, in the preferred embodiment of the present invention, control processes are specified by functional diagrams which use logic and circuit-like functional elements to describe the relationship between the system's input signals and its output signals.
Automatic code generators are typically perceived as having two main advantages: (1) they eliminate the need for the user to know the computer lauguage in which the code is written; and (2) they generate reliable code, free from the mistakes typically made by inexperienced, and sometimes even veteran, computer programmers.
The advent of automatic code generation has been spurred primarily by the proliferation of (1) unskilled computer users, and (2) complex real time control problems.
The present invention is specifically directed at generating computer software for complex real time control systems, and particularly multirate systems. A multirate system is a system which needs to simultaneously perform at least two (and typically a multiplicity of) tasks at different rates.
A major difficulty in designing software for a multirate real time system is producing reliable code. In particular, the generated software must react to input signals and generate output control signals in an entirely predictable fashion. Given the potential complexity of multirate systems, the solution to this problem has not been immediate.
The present invention provides a system and method for generating software which will reliably control any multirate real time system. The only constraint is that the computer(s) used to run the generated code must have enough throughput capability to perform the necessary computations. But even here, the code generated by the preferred embodiment automatically detects if the computer(s) running the generated code are not sufficiently fast for the application.
An important feature of the present invention is the division of the software into separate subsystems for each rate in the system, and the provision of a software interface which controls the passing of information between subsystems. In other words, all the software which must run at each rate is collected into a separate unit called a subsystem. The software interface deterministically specifies when the input data for each subsystem is passed from its source(s) to the subsystem.
In particular, the software interface uses a "zero order hold" which insures that the outputs from each subsystem are passed to other subsystems only after all the computations for a particular computation cycle are complete. In other words, the zero order hold ensures that all the outputs from a subsystem are internally consistent and not in a state of flux.
Further, in the preferred embodiment, the zero order hold contains two buffers called BUS0 and BUS1. During each computation cycle one buffer is used to store new output values and the other is used to hold the outputs computed during the previous computation cycle. Then, at the beginning of each new computation cycle the role of these two buffers is switched. Thus the zero order hold makes the outputs of each subsystem piecewise constant--all of the subsystem's output change simultaneously and change only at predefined times.
A second essential aspect of the software interface is a software sample and hold for the inputs to each subsystem. At the beginning of each subsystem's computation cycle all the inputs to that subsystem from other subsystems are "sampled and held", i.e., copied into a buffer. This ensures that these input values do not fluctuate during the time it takes to perform the subsystem's calculations.
The software interface is important in a multirate control system because at any given time more than one subsystem's calculations may be in various stages of completion. The software interface ensures that "half backed" output signals from one subsystem cannot be used as inputs by another because each subsystem's outputs become available for use by other subsystems only after the subsystem's computations are complete. Also, these outputs are updated (i.e., the roles of BUS0 and BUS1 are switched) in accordance with a predefined schedule. Failure to control the flow of signals in this way in a multirate control system can cause unpredictable results--which is clearly undesirable.
An important aspect of division of the generated code is the automatic generation of a scheduler program which controls when each subsystem's code is run and the priority given to each subsystem's computations. In "stand alone" systems, the scheduler can be used as the system's operating system.
Another feature of the present invention is that the code generated by the system is designed to be useable on both single processor and multiprocessor control systems. The software interfaces between subsystems provide a "natural" dividing line between tasks that can be performed on separate processors.
Still another feature of the present invention is that the code portions and equations within each subsystem are automatically ordered to promote reliable computation and proper propagation of data through the subsystem. This is done by classifying the subsystem's elements and then using a predefined algorithm which sorts the subsystem's elements so that, to the extent possible, the code portion for each element is executed only after its input data from other portions of the same subsystem is calculated.
It is therefore a primary object of the present invention to provide a system and method for automatically generating computer software to control multirate real time systems.